﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XrmLibrary.MsCrm4Adapter.Extensions
{
    public static class LocLabelExtensions
    {
        public static Microsoft.Xrm.Sdk.LocalizedLabel ToCrm2011LocalizedLabel(this Microsoft.Crm.Sdk.LocLabel crm4LocLabel)
        {
            Microsoft.Xrm.Sdk.LocalizedLabel crm2011LocalizedLabel = new
             Microsoft.Xrm.Sdk.LocalizedLabel
             {
                 Label = crm4LocLabel.Label,
                 LanguageCode = crm4LocLabel.LanguageCode.Value
             };

            return crm2011LocalizedLabel;
        }

        public static IEnumerable<Microsoft.Xrm.Sdk.LocalizedLabel> ToCrm2011LocalizedLabelCollection(this Microsoft.Crm.Sdk.LocLabel[] crm4LocLabel)
        {
            foreach (Microsoft.Crm.Sdk.LocLabel locLabel in crm4LocLabel)
            {
                yield return locLabel.ToCrm2011LocalizedLabel();
            }
        }
    }
}
